﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Gui.Util
{
    class CodeChecker
    {
        static readonly string Prefix = "88.382.00001/";
        static readonly string MaterialPrefix = Prefix + "01";
        static readonly string PersonPrefix = Prefix + "02";
        static readonly string ProductPrefix = Prefix + "03";
        static readonly string ValidPattern1 ="^"+ Prefix + @"(\w{10})$";
        static readonly string ValidPattern2 = "^" + Prefix + @"(\w{32})$";

        internal static bool IsValidCode(string code)
        {
            //var match = Regex.Match(code, ValidPattern1+ "|" + ValidPattern2);
            //return match.Success;
            return code.Length == 13;
        }
        internal static bool IsMaterial(string code)
        {
            return code.StartsWith(MaterialPrefix) && code.Length - Prefix.Length == 32;
        }

        internal static bool IsPerson(string code)
        {
            //return code.StartsWith(PersonPrefix) && code.Length - Prefix.Length == 10;
            return true;
        }

        internal static bool IsProduct(string code)
        {
            return code.StartsWith(ProductPrefix) && code.Length - Prefix.Length == 32;
        }
    }
}
